package com.hb.medical_research_system.controller;

import com.hb.medical_research_system.common.Results;
import com.hb.medical_research_system.entity.Result;
import com.hb.medical_research_system.service.ResultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "搜索结果")
@Slf4j
@RestController
@RequestMapping("/result")
public class ResultController {

    private final ResultService resultService;

    @Autowired
    public ResultController(ResultService resultService) {
        this.resultService = resultService;
    }

    @ApiOperation("新增结果接口,直接新增")
    @PostMapping("/add")
    public Results addResult(@RequestBody Result result){
        return resultService.add(result);
    }

    @ApiOperation("新增结果接口,检查是否已有后新增,已有则修改数据")
    @PostMapping("/checkadd")
    public Results addCheckResult(@RequestBody Result result){
        return resultService.check(result);
    }
}
